<template>
  <div>
    <div class="top_img" :style="'background-image: url(' + topBg + ')'">
      <span>校 园 资 讯</span>
    </div>
    <div class="main">
      <div class="title">
        {{ initData.title }}
      </div>
      <div class="small">
        {{
          $moment(parseInt(initData.publishTime)).format("YYYY-MM-DD HH:mm:ss")
        }}
      </div>
      <div class="img_box">
        <img :src="initData.imagesUrl" width="100%" alt="" />
      </div>
      <div class="content">
        {{ initData.content }}
      </div>
      <div class="content" v-if="initData.content1">
        {{ initData.content1 }}
      </div>
      <div class="content" v-if="initData.content2">
        {{ initData.content2 }}
      </div>
      <div class="content" v-if="initData.content3">
        {{ initData.content3 }}
      </div>
      <div class="content" v-if="initData.content4">
        {{ initData.content4 }}
      </div>
    </div>
  </div>
</template>
<script>
import { getByIdNews } from "@/util/news.js";

export default {
  data() {
    return {
      topBg:
        "http://175.178.92.128:8087/campus_help_system/images/insidePages/20190910163919740.jpg",

      initData: {},
    };
  },
  created() {
    this.getByIdNews();
  },
  mounted() {},
  methods: {
    // 获取数据
    async getByIdNews() {
      let { data: res } = await getByIdNews({ id: this.$route.params.id });
      console.log(res);
      this.initData = res.data;
    },
  },
};
</script>
<style lang="less" scoped>
.top_img {
  height: 280px;
  background-repeat: no-repeat;
  background-size: auto 100%;
  background-position: center center;
  display: flex;
  align-items: center;
  justify-content: center;
  & > span {
    font-size: 48px;
    font-weight: 700;
    color: #fff;
  }
}
.main {
  padding: 50px 0;
  width: 1200px;
  margin: 0 auto;
  text-align: center;
  .title {
    font-size: 28px;
    margin-bottom: 24px;
  }
  .small {
    text-align: center;
    font-size: 14px;
    color: #999;
    margin-bottom: 24px;
  }
  .img_box {
    margin: 0 auto;
    width: 800px;
    margin-bottom: 48px;
  }
  .content {
    text-align: left;
    margin-bottom: 24px;
    font-size: 16px;
    line-height: 26px;
    color: #333;
    text-indent: 2em;
  }
}
</style>
